'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _database = require('../config/database');

var _database2 = _interopRequireDefault(_database);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }

const createCard = (() => {
  var _ref = _asyncToGenerator(function* (accountInfo) {
    let cardInfo = null;
    var accountkeys = Object.keys(accountInfo);
    var accountvalues = [];
    for (let key in accountkeys) {
      accountvalues.push(accountInfo[accountkeys[key]]);
    }
    let sql = `INSERT INTO t_agent_add_cards_to_agent(${accountkeys})
    VALUES(${accountvalues})`;
    try {
      console.log(sql);
      cardInfo = yield _database2.default.query(sql);
      console.log('add t_agent_add_cards_to_agent success');
    } catch (err) {
      console.log(`create t_agent_add_cards_to_agent ${err}`);
    }
    return cardInfo;
  });

  return function createCard(_x) {
    return _ref.apply(this, arguments);
  };
})();

exports.default = {
  createCard
};